Completed
Push — master ( 8c53f9...1d869a )
by Marcelo
33s
created

run.spec.js ➔ ???   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 27
rs 8.8571
nop 0
1
import { delay } from 'bluebird';
2
import { expect } from 'chai';
3
import path from 'path';
4
import intercept from 'intercept-stdout';
5
import { createStream } from './helper';
6
7
describe('run.js', () => {
8
    describe('Execution', () => {
9
        it('should execute a hello world', () => {
10
            process.chdir(path.join(__dirname, 'data/hello-world'));
11
            const stream = createStream(['run'], '../../../dist/cli.js');
12
13
            return stream.once('data')
14
                .then(askName => {
15
                    expect(askName).to.match(/What is your name/);
16
                    return stream.write('Harmony\n\n');
17
                })
18
                .then(() => {
19
                    let result = '';
20
                    const stopReading = intercept(text => result += text);
21
                    return delay(5000)
22
                        .then(() => {
23
                            stopReading();
24
                            expect(result).to.equals('');
25
                        });
26
                })
27
                .finally(() => {
28
                    stream.close();
29
                    process.chdir(path.join(__dirname, '..'));
30
                });
31
        }).timeout(25000);
32
    });
33
});
34